<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>长微博发布</title>
<link href="umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
<style type="text/css">
body{
	margin: 0;
	padding: 0;
}
h1 {
	font-family: "微软雅黑";
	font-weight: normal;
}
</style>
</head>
<body>
<div style="margin-left: 100px;">
	<h1>长微博生成器</h1>
	<script type="text/plain" id="myEditor"></script>
	<div style="float: left; left: 580px; top: 300px; position: absolute;">
		<p><button class="btn" onclick="saveLongWeibo(2)" />网址生成</button></p>
		<p><button class="btn" onclick="saveLongWeibo(1)" />保存长微博</button></p>
	</div>
	<div id="preview" style="float: left; left: 700px; top: 50px; position: absolute;">
		<h1>长微博预览图(点击查看大图)</h1>
		<img alt="长微博" src="http://i1.tietuku.com/631208cdf03be943.png"
		onclick="javascript:window.open('http://i1.tietuku.com/631208cdf03be943.png')"
		style="border: 2px solid red; cursor: pointer;" width="450" height="650"/>
		<div class="link"></div>
	</div>
</div>

<script type="text/javascript" src="umeditor/third-party/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="umeditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="umeditor/umeditor.min.js"></script>
<script type="text/javascript" src="umeditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
	var um_width = 450, um_height = 650;
    //实例化编辑器
    var um = UM.getEditor('myEditor', {
    	initialFrameWidth : um_width,
    	initialFrameHeight : um_height
    });
    
    function saveLongWeibo(type){
    	//内容
    	var content = '';
    	if(type==1){
    		content = UM.getEditor('myEditor').getContent();
    		if(content == ''){
    			alert('请输入内容');
        		return;
    		}
    	}
    	if(type==2){
    		content = UM.getEditor('myEditor').getContentTxt();
    		if(content == ''){
    			alert('输入网址');
        		return;
    		}
    	}
    	$('#result').html('正在转换,请稍后...');
    	var params = {
    		width : um_width,
    		height : um_height,
    		type : type,
    		content : content
    	};
    	$.post('/longweibo/covert_toimg', params, function(data){
    		if(data){
    			$('#preview img').attr('src', data).show().attr('onclick','javascript:window.open("'+data+'")');
    			$('#result').html('');
    		}
    	});
    }
</script>
</body>
</html>